home *** CD-ROM | disk | FTP | other *** search
- :Batutil c(o) 1990, 1991 Barry Simon and Richard Wilson
- : Version 4.0
- echo off
- cls
- batutil {inc %0 code}
- goto end
- :echo1
- Welcome to the @1FBATUTIL@1E user input demo
- This demonstration will show how BATUTIL can get
- information from the user.
-
- :echo2
-
- The first way to get information is the GETKEY command. We'll try
- @1FBATUTIL {GE y n}
- and you'll need to reply with one key or the other. Your choice will get
- echoed on the screen; it can get returned in the errorlevel or the
- environmental variable RC. Now
-
- Please hit Y or N :
- :echo3
-
- GETKEY is case insensitive and flushes the keyboard buffer before looking
- for a response but you can change that or change whether there is a visible
- echo. You can specify that a wrong choice get beeped or that a choice not on
- the list just returns a special errorlevel. You can have BATUTIL exit with
- errorlevel 0 if there is no response in a specified time. You can even
- have the time shown in a ticking clock on screen. We'll show you the
- effect of
- @1FBATUTIL {EC You have $$L seconds left}{GE WA12 EL}
- after you hit any key.
-
-
- :echo4
-
-
- BATUTIL will also pop up a menu for you to choose from with the choice
- returned in the errorlevel. The file menudemo.bat illustrates this or, if
- you are running this as a choice from the main demo program, just choose
- the MENU DEMONSTRATION from the main menu.
-
- You can test for whether the CAPSLOCK key is pressed and branch on that; this
- is ideal for making a choice at the start of a long batch file and then
- leaving the room.
- @1FBATUTIL {QL C -}
- will return errorlevel 1 if on and 0 if off and turn it off if on.
-
- Please hit CAPSLOCK and then another key to continue.
-
-
- :echo5
- The errorlevel return was $r.
-
- BATUTIL will also allow you to place strings in the environment. First we'll
- ask you to input a string and then to choose a filename from BATUTIL's file
- picker. Be sure to scroll to the bottom of the file list to see what can be
- done. Now hit a key to continue.
-
-
- :echo6
-
-
- The string you entered was
- $S $0
- and the filename was
- $S $1
- with a path of $2
-
- You can also get numbers as input and do arithmetic on them.
- Please enter a pair of numbers:
- :echo7
-
- Their sum is $V($1+$2) and their difference is $V($1-$2).
-
- Thanks for using BATUTIL. Hit a key to exit.
-
- :code
- RC $
- CU - }{ CLS }{ RO 2 }{ CO 1
- FP %0 echo1 }{ GE WA2 }{ EC $_
- FP %0 echo2 }{ GE y n
- EC $_You picked choice $r$_
- FP %0 echo3 }{ GE EL
- EC You have $L seconds left (or hit a key) }{ GE WA12 EL
- CL }{ FP %0 echo4 }{ GE EL }{ QL C -
- FE %0 echo5 }{ GE EL
- CL }{ EC $_$_Input a string$S }{ $0=$Q }{ RO -1 }{ EOL +
- FD $2 {$1=$F } FD FDIR {FE %0 echo6
- REM notice the use of FD $2 to store directory in an internal variable
- echoln }{ $1=$N
- $2=$N
- FE %0 echo7
- {RO T0}{CO T0}{GE WA5 EL}{EC $_}
- :end
-
-